
package Taxi.ops;

/**
 *
 * @author BIGBOSS
 */
import javax.swing.table.AbstractTableModel;
import java.sql.*;
import java.util.ArrayList;

/**
 *
 * @author BIGBOSS
 */
public class OperationsTableModel extends AbstractTableModel {

    private int colnum = 10;
    private int rownum;
    private String[] colNames = {
        "Id", "Taxi Number", "Driver", "Start Odometer", "End Odometer", "Plate Number", "Start Date", "End Date", "Boundary", "Taken Boundary"
    };
    private ArrayList<String[]> Rows;

    /** Creates a new instance of FoodTableModel */
    public OperationsTableModel(ResultSet rs) {

        Rows = new ArrayList<String[]>();

        try {
            while (rs.next()) {

                String[] row = {
                    String.valueOf(rs.getInt("id")),
                    rs.getString("unitnumber"), rs.getString("driver"),
                    rs.getString("startodometer"), rs.getString("endodometer"),
                    rs.getString("platenumber"), rs.getString("start_date"), rs.getString("end_date"),
                    rs.getString("boundary"), rs.getString("taken_boundary")
                };
                Rows.add(row);

            }
        } catch (Exception e) {
            System.out.println("Exception in OperationsModel");
        }

    }

    public Object getValueAt(int rowindex, int columnindex) {

        String[] row = Rows.get(rowindex);
        return row[columnindex];

    }

    public int getRowCount() {
        return Rows.size();
    }

    public int getColumnCount() {
        return colnum;
    }

    public String getColumnName(int param) {

        return colNames[param];
    }


}
